from django.core.paginator import Paginator, PageNotAnInteger, EmptyPage


def get_page(objects, p):
    paginator = Paginator(objects, 10)
    try:
        page = paginator.page(p)
    except PageNotAnInteger:
        page = paginator.page(1)
    except EmptyPage:
        page = None
    return page.object_list if page else [], \
           page.has_next() if page else False
